package com.atguigu.day02.transform;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class Flink09_Union {
    public static void main(String[] args) {
         Configuration conf = new Configuration();
          //配置web页面固定端口
          conf.setInteger("rest.port", 20000);
          //创建流环境
          StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
          //设置并行度
          env.setParallelism(2);

        DataStreamSource<String> first = env.fromElements("a", "b", "c", "d");
        DataStreamSource<String> second = env.fromElements("1", "2", "10", "20", "30");

        //可以把多个流合成一个流
        //流的数据类型必须一致
         first.union(second,second).print();

        try {
              env.execute();
          } catch (Exception e) {
              e.printStackTrace();
          }
    }
}
